#include <iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int i,a[1000],b[1000],top=0;
	cin>>a[0];
	for(i=1;i<n;i++)
	{
		cin>>a[i];
		if(a[i]<=a[0])
			b[++top]=a[i];
	}
	while(top)
		cout<<b[top--]<<" ";
	cout<<a[0]<<" ";
	for(i=1;i<n;i++)
		if(a[i]>a[0])
			cout<<a[i]<<" ";
	return 0;
}